/**
 * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
 */
// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作
const install = (Vue, vm) => {

	// 参数配置对象vuex_config
	const config = vm.vuex_config;

	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		//公告
		getNoticeListAll:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/noticeListAll',params),
		//我的工作记录
		getMyWorkRecord:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/employee/getMyWorkRecord',params),
		//打卡上岗工作接口
		signWork:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/employee/work',params),
		//根据工位id获取工位信息
		getWorkstationById:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/employee/getWorkstationById',params),
		//根据岗位id获取岗位信息
		getWorkPostById:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/employee/getWorkPostById',params),
		//保存微信用户到员工表中
		saveUserInfo:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/employee/saveUserInfo',params),
		//获取员工的电话
		getPhoneNumber:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/employee/getPhoneNumber?code='+params),
		//检查员工是否注册
		isUserReg:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/employee/isUserReg?openid='+params),
		//获取openid
		getOpenId:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/employee/getOpenId?code='+params),
		//获取表单详情
		getOrderInfo:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/form/getRecordById',params),
		//获取全部表单列表
		getListALL:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/form/listAll',params),
		//获取表单列表
		getOrderList:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/form/listRecord',params),
		//获取表单内容
		getOrderContent:(params = {}) => vm.$u.get(config.baseUrl + '/wechat/form/'+params),
		//新增 检点记录
		checkpointRecord:(params = {},header) => vm.$u.post(config.baseUrl + '/wechat/form/addRecord',params),
		//login
		login:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/employee/login',params),
		//checkLogin
		checkLogin:(params = {}) => vm.$u.post(config.baseUrl + '/wechat/employee/checkLogin',params),
		
		// 基础服务：登录登出、身份信息、菜单授权、切换系统、字典数据等
		lang: (params = {}) => vm.$u.get('/lang/' + params.lang),
		index: (params = {}) => vm.$u.get(config.adminPath + '/mobile/index', params),
		getUserInfo: (params = {}) => vm.$u.get(config.adminPath + '/mobile/user/getUserInfo', params),
		houTaiLogin: (params = {}) => vm.$u.postJson(config.adminPath + '/login', params),
		sendCode: (params = {}) => vm.$u.post(config.adminPath + '/mobile/login/sendCode', params),
		registerUser: (params = {}) => vm.$u.post(config.adminPath + '/mobile/user/registerUser', params),
		//修改密码
		updatePwd: (params = {}) => vm.$u.put(config.adminPath + '/system/user/profile/updatePwd', params),
		//获取基本资料
		getProfile: () => vm.$u.get(config.adminPath + '/system/user/profile'),
		//修改基本资料
		updateProfile: (params = {}) => vm.$u.putText(config.adminPath + '/system/user/profile', params),

		//首页相关api
		getIndexCardInfo: (params = {}) => vm.$u.get(config.adminPath + '/mobile/index/getIndexCardInfo',
			params),
		getM2mOrderFlowList: (params = {}) => vm.$u.get(config.adminPath + '/mobile/index/getM2mOrderFlowList',
			params),
		//获取卡可购买套餐包
		getM2mOrderPackageList: (params = {}) => vm.$u.get(config.adminPath +
			'/mobile/index/getM2mOrderPackageList', params),

		logout: (params = {}) => vm.$u.get(config.adminPath + '/logout', params),
		authInfo: (params = {}) => vm.$u.get(config.adminPath + '/authInfo', params),
		menuTree: (params = {}) => vm.$u.get(config.adminPath + '/menuTree', params),
		switchSys: (params = {}) => vm.$u.get(config.adminPath + '/switch/' + params.sysCode),
		dictData: (params = {}) => vm.$u.get(config.adminPath + '/system/dict/data/type/' + params.dictType),


		// 账号服务：验证码接口、忘记密码接口、注册账号接口等
		validCode: (params = {}) => vm.$u.getText('/validCode', params),
		getFpValidCode: (params = {}) => vm.$u.post('/account/getFpValidCode', params),
		savePwdByValidCode: (params = {}) => vm.$u.post('/account/savePwdByValidCode', params),
		getRegValidCode: (params = {}) => vm.$u.post('/account/getRegValidCode', params),
		saveRegByValidCode: (params = {}) => vm.$u.post('/account/saveRegByValidCode', params),

		// APP公共服务
		upgradeCheck: () => vm.$u.post('/app/upgrade/check', {
			appCode: config.appCode,
			appVersion: config.appVersion
		}),
		commentSave: (params = {}) => vm.$u.post('/app/comment/save', params),
		getInfo: (params = {}) => vm.$u.get(config.adminPath + '/getInfo', params),

		// 个人信息修改
		user: {
			saveUserInfo: (params = {}) => vm.$u.post(config.adminPath + '/mobile/user/saveUserInfo', params),
			infoSavePwd: (params = {}) => vm.$u.put(config.adminPath + '/system/user/profile/updatePwd',
				params),
			infoSavePqa: (params = {}) => vm.$u.post(config.adminPath + '/sys/user/infoSavePqa', params),
			treeselect: (params = {}) => vm.$u.get(config.adminPath + '/system/dept/treeselect', params),
			listUser: (params = {}) => vm.$u.get(config.adminPath + '/system/user/list', params),
		},

		// 员工用户查询
		empUser: {
			listData: (params = {}) => vm.$u.get(config.adminPath + '/sys/empUser/listData', params),
		},

		// 组织机构查询
		office: {
			treeData: (params = {}) => vm.$u.get(config.adminPath + '/sys/office/treeData', params),
		},

		// 增删改查例子
		testData: {
			form: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/form', params),
			list: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/listData', params),
			save: (params = {}) => vm.$u.postJson(config.adminPath + '/test/testData/save', params),
			disable: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/disable', params),
			enable: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/enable', params),
			delete: (params = {}) => vm.$u.post(config.adminPath + '/test/testData/delete', params),
		},
		// 设备管理
		device: {
			list: (params = {}) => vm.$u.get(config.adminPath + '/device/device/list', params),
			listAll: (params = {}) => vm.$u.get(config.adminPath + '/device_group/listAll', params),
			detail: (params = undefined) => vm.$u.get(config.adminPath + '/device/device/' + params),
			getInfoByCode: (params = undefined) => vm.$u.get(config.adminPath + '/device/device/getInfoByCode/' + params),
			listGroupBySubSystem: (params = {}) => vm.$u.get(config.adminPath +
				'/device/device/listGroupBySubSystem', params),
			deviceGroupList: (params = {}) => vm.$u.get(config.adminPath +
				'/device_group/list', params),
			getPositionNameById: (params = undefined) => vm.$u.get(config.adminPath +
				'/park/position/getPositionNameById/' +
				params),
			qrCodeDevice: (params = {}) => vm.$u.get(config.adminPath + '/common/QR/qrCodeDevice', params),
		},
		// 维保
		maintenance: {
			list: (params = {}) => vm.$u.get(config.adminPath + '/workorder/maintenancetask/list', params),
		},
		// 维保
		maintenance: {
			list: (params = {}) => vm.$u.get(config.adminPath + '/workorder/maintenancetask/list', params),
			getMaintenancetask: (id) => vm.$u.get(config.adminPath + '/workorder/maintenancetask/' + id),
			// 查询maintenancehistory列表
			listMaintenancehistory: (params = {}) => vm.$u.get(config.adminPath + '/workorder/maintenancehistory/list',
				params),
			//完成maintenancetask
			completeMaintenancetask: (params = {}) => vm.$u.postJson(config.adminPath +
				`/workorder/maintenancetask/complete`, params),
			//按类型查询maintenancetask列表
			listMaintenancetaskByType: (params = {}) => vm.$u.postJson(config.adminPath +
				`/workorder/maintenancetask/listByType/` + type),
		},
		//工单
		workOrder: {
			list: (params = {}) => vm.$u.get(config.adminPath + '/order/list', params),
			getlotFinish0rders: (params = {}) => vm.$u.get(config.adminPath + '/order/nofinished', params),
			detail: (params = {}) => vm.$u.get(config.adminPath + '/order/detail/' + params.id, params.params),
			insert: (data) => vm.$u.postJson(config.adminPath + `/order/insert`, data, {
				'content-type': `multipart/form-data; boundary=----WebKitFormBoundaryRv0nvCU2ubDlTjjX`,
			}),
			comments: (params = {}) => vm.$u.get(config.adminPath + '/order/comments/' + params.id, params.params),
			commentsInsert: (params = {}) => vm.$u.postJson(config.adminPath + `/order/comments/insert`, params),
			status: (params = {}) => vm.$u.putText(config.adminPath + '/order/status', params),
		},
		// 根据字典类型查询字典数据信息
		getDicts: (dictType) => vm.$u.get(config.adminPath + '/system/dict/data/type/' + dictType),
		//抄表
		meterReading: {
			list: (params = {}) => vm.$u.get(config.adminPath + '/meter/meter/list', params),
			getInfoByDeviceCode: (deviceCode) => vm.$u.get(config.adminPath +
				`/meter/meter/getInfoByDeviceCode/${deviceCode}`),
			getMeter: (meterId) => vm.$u.get(config.adminPath + '/meter/meter/' + meterId),
			listMeterRecordAll: (params = {}) => vm.$u.get(config.adminPath + '/meter/meterRecord/listAll', params),
			addMeterRecord: (params = {}) => vm.$u.postJson(config.adminPath + `/meter/meterRecord`, params),
		},
		//位置
		park: {
			listAll: (params = {}) => vm.$u.get(config.adminPath + '/park/position/listAll', params),
		},
		visitor: {
			list: (params = {}) => vm.$u.get(config.adminPath + '/visitor/visitorInfo/list', params),
			check: (params = {}) => vm.$u.get(config.adminPath + '/visitor/visitorInfo/check', params),
			// 已来访
			already: (params = {}) => vm.$u.get(config.adminPath + '/visitor/visitorInfo/already', params),
			// 已离园
			departure: (params = {}) => vm.$u.get(config.adminPath + '/visitor/visitorInfo/departure', params),
			// 拒绝
			refuse: (params = {}) => vm.$u.get(config.adminPath + '/visitor/visitorInfo/refuse', params),
			// 通过
			allow: (params = {}) => vm.$u.get(config.adminPath + '/visitor/visitorInfo/allow', params),
			getVisitorInfo: (visitorInfoId) => vm.$u.get(config.adminPath + '/visitor/visitorInfo/' + visitorInfoId),
			// 通过
			getApprovedQR: (params = {}) => vm.$u.get(config.adminPath + '/visitor/visitorInfo/getApprovedQR', params),
			// 获取全部区域
			getRegionAll: (params = {}) => vm.$u.get(config.adminPath + '/visitor/region/listAll', params),
			// 获取全部区域
			getStatusList: (params = {}) => vm.$u.get(config.adminPath + '/visitor/visitorInfo/getStatusList', params),
			// 验证岗亭是否登录
			sentryBoxCheckLogin: (params = {}) => vm.$u.get(config.adminPath + '/visitor/sentryBox/checkLogin', params),
			// 岗亭登录
			sentryBoxLogin: (params = {}) => vm.$u.get(config.adminPath + '/visitor/sentryBox/login', params),
			// 岗亭全部列表
			sentryBoxListAll: (params = {}) => vm.$u.get(config.adminPath + '/visitor/sentryBox/listAll', params),
			// 获取我的岗亭
			getMySentryBox: (params = {}) => vm.$u.get(config.adminPath + '/visitor/sentryBox/getMySentryBox', params),
		},
		xinpeng: {
			work: (params = {}) => vm.$u.get(config.adminPath + '/xinpengservice/employeePostRecord/work', params),
			checkpointRecordList: (params = {}) => vm.$u.get(config.adminPath + '/xinpengservice/checkpointRecord/list', params),
			checkpointRecordInfo: (id) => vm.$u.get(config.adminPath + '/xinpengservice/checkpointRecord/' + id),
			postInfo: (id) => vm.$u.get(config.adminPath + '/xinpengservice/post/' + id),
			postListAll: (params = {}) => vm.$u.get(config.adminPath + '/xinpengservice/post/listAll', params),
			workstationInfo: (id) => vm.$u.get(config.adminPath + '/xinpengservice/workstation/' + id),
			workstationListAll: (params = {}) => vm.$u.get(config.adminPath + '/xinpengservice/workstation/listAll', params),
		}
	};
}

export default {
	install
}